{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "## 导入模块\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "outputs": [],
   "source": [
    "## 创造实验数据\n",
    "x0 = np.arange(1,16).reshape(-1,1)  # 这里我们选取15个点，将数组转换为列向量\n",
    "## 使用 y = (x-5)^2 = x^2+10*x+25, 作为模型函数并添加噪声\n",
    "y0 = ((x0-5)**2 + np.random.uniform(0,10,size=(len(x0),1))).reshape(-1,1)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  50]\n",
      " [ 100]\n",
      " [ 200]\n",
      " [ 500]\n",
      " [1000]\n",
      " [2000]]\n",
      "[ 15  20  35  50  80 120]\n"
     ]
    }
   ],
   "source": [
    "## 创造实验数据\n",
    "x0 = np.array([50,100,200,500,1000,2000]).reshape(-1,1)\n",
    "y0 = np.array([15,20,35,50,80,120])\n",
    "print(x0)\n",
    "print(y0)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "outputs": [],
   "source": [
    "'''\n",
    "该特性矩阵一共有三列，第一列为全为1，第二列为向量x，第三列为向量x^2\n",
    "'''\n",
    "first = np.ones((len(x0))).reshape(-1,1) # -1生成-1行1列,-1即任意多行\n",
    "second = x0\n",
    "third = x0**2\n",
    "forth = x0**3\n",
    "X = np.concatenate((first, second, third, forth), axis=1)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% 构造特性矩阵\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "outputs": [],
   "source": [
    "X_T = X.transpose()\n",
    "beta = np.linalg.inv(X_T.dot(X)).dot(X_T).dot(y0)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% 求解系数 θ=(XTX)XTy\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "系数矩阵:\n",
      "[ 1.25133095e+01  8.99183907e-02 -1.86862200e-05 -4.00958881e-09]\n"
     ]
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXxU5aH/8c9DNsIalhCyEpB9B0PAtVatuFFwQYGgqLTUVq3duMK1v3rvta1a1La31irFBSGsiuDSihb31gQCAcIW9oQskLAECIQsk+f3RwZvpAmQTDJnZvJ9v168MnPmTObLmeHLmWfmnMdYaxERkcDSyukAIiLS9FTuIiIBSOUuIhKAVO4iIgFI5S4iEoCCnQ4A0LVrV5uYmOh0DBERv7J+/frD1trIum7ziXJPTEwkIyPD6RgiIn7FGJNT320alhERCUAqdxGRAKRyFxEJQCp3EZEApHIXEQlAFyx3Y8yrxpgiY8yWWsvmGGN2GGM2G2PeNsZE1LpttjFmtzEm2xgztrmCi4j4s5WZ+Vzx9Mf0nPU+Vzz9MSsz85v091/MnvvrwI3nLPsIGGytHQrsBGYDGGMGApOAQe77vGiMCWqytCIiAWBlZj6zV2SRX1KGBfJLypi9IqtJC/6C5W6t/Rw4es6yD621Ve6raUCc+/J4YIm1ttxauw/YDSQ3WVoRkQAwZ3U2ZZWubywrq3QxZ3V2kz1GU4y5PwD83X05FjhQ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AElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "yi = beta[0] + beta[1] * x0 + beta[2] * (x0 ** 2)\n",
    "\n",
    "fig = plt.figure()\n",
    "sub = plt.subplot(111)\n",
    "sub.scatter(x0, y0)\n",
    "sub.plot(x0, yi)\n",
    "\n",
    "print(\"系数矩阵:\\n{0}\".format(beta))\n",
    "plt.show()\n",
    "\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% 画图\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}